package team.seekers.oj.auth.api;


import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.*;
import team.seekers.oj.auth.dto.PermissionDTO;
import team.seekers.oj.common.util.RedisConstants;

import java.util.List;
import java.util.Map;

@RequestMapping("/internal/auth")
public interface PermissionApi {
    String SERVICE_NAME = "user-service";

    /**
    * @Description 同步微服务 URL 到权限中心
    **/
    @PostMapping(value = "/sync", consumes = "application/json")
    void sync(@RequestBody List<PermissionDTO> permissionDTOList);

    /**
    * @Description 查询所有url权限信息
    **/
    @GetMapping(value = "/listAll")
//    @Cacheable(value = RedisConstants.ALL_URL_PERMISSION)
    List<PermissionDTO> listAll();



    @GetMapping(value = "/queryUrlToRolesMap")
//    @Cacheable(value = RedisConstants.URL_TO_ROLES_MAP)
    Map<String, List<String>> queryUrlToRolesMap();





    @GetMapping(value = "/urlToRoles")
//    @Cacheable(key = "#url", value = RedisConstants.URL_TO_ROLES)
    List<String> urlToRoles(@RequestParam("url") String url);
}